﻿using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.Permission;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
/// <summary>
/// 应收单列表插件
/// </summary>
/// <remarks>
/// 功能：1、点击获取成本按钮，弹出动态表单
///         2、点击获取转移价成本，弹出动态表单
/// 创建人：lxl
/// 创建日期：2024-5-16
/// 修改信息（1）：修改人，修改日期，修改内容
/// </remarks>
namespace LM.YF.K3Cloud.Plugin
{
    [HotUpdate, Description("应收单列表插件")]
    public  class ReceivableListPlugin:AbstractListPlugIn
    {
        public override void AfterToolBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterToolBarItemClick(e);
            //获取菜单项
            if (e.BarItemKey.ToUpper() == "DEV_BTGETCOSTPRICE")//获取生产成本
            {
                //弹出动态表单
                // 打开采购初始化指引界面
                var showParameter = new DynamicFormShowParameter();
                showParameter.FormId = "QLTK_GETPRODUCTCOST";//表单标识
                //showParameter.CustomParams.Add("FType", "0");//0:获取成本参考价格，1：获取转移价格
                showParameter.PageId = Guid.NewGuid().ToString();
                showParameter.ParentPageId = this.View.PageId;
                showParameter.PermissionItemId = PermissionConst.View;
                this.View.ShowForm(showParameter);

            }
        }
        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterBarItemClick(e);
            //获取菜单项
            if(e.BarItemKey.ToUpper()=="DEV_BTGETCOSTPRICE")//获取生产成本
            {
                //弹出动态表单
                var showParameter = new DynamicFormShowParameter();
                showParameter.FormId = "QLTK_GETPRODUCTCOST";
                showParameter.PageId = Guid.NewGuid().ToString();
                showParameter.ParentPageId = this.View.PageId;
                showParameter.PermissionItemId = PermissionConst.View;
                this.View.ShowForm(showParameter,delegate (FormResult result)
                { 
                    //获取成功后，刷新数据
                    if(result!=null && result.ReturnData=="sucess")
                    {
                        this.ListView.Refresh();//刷新列表
                    }
                }
                );
                              
            }
            //获取转移价
            if (e.BarItemKey.ToUpper() == "QLTK_TBBTZYJ")//获取转移价
            {
                //弹出动态表单
                var showParameter = new DynamicFormShowParameter();
                showParameter.FormId = "QLTK_GETZYJ";
                showParameter.PageId = Guid.NewGuid().ToString();
                showParameter.ParentPageId = this.View.PageId;
                showParameter.PermissionItemId = PermissionConst.View;
                this.View.ShowForm(showParameter, delegate (FormResult result)
                {
                    //获取成功后，刷新数据
                    if (result != null && result.ReturnData == "sucess")
                    {
                        this.ListView.Refresh();//刷新列表
                    }
                }
                );

            }

        }
    }
}
